package leetcode.hot100;

import datastruct.tree.TreeNode;

public class Solution101 {
    /**
     * 对称二叉树
     */
    public boolean isSymmetric(TreeNode root) {
        if(root==null) return true;
        return isSym(root.left,root.right);
    }

    public boolean isSym(TreeNode left, TreeNode right){
        //判断两棵树是否镜像
        if(left==null&&right==null) return true;
        if(left==null||right==null) return false;
        if(left.val!=right.val) return false;
        return isSym(left.left,right.right)&&isSym(left.right,right.left);
    }
}
